﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel;
using System.Drawing;
using System.Reflection;
using System.Drawing.Design;

namespace CommonLibrary.CustControls
{
    /// <summary>
    /// 表单设计器加载的自定义控件
    /// </summary>
    class CustControl
    {

    }

    #region 自定义表单控件
    public enum Limitypes
    {
        长度限制,
        格式验证,
    }

    public enum textAlign
    {
        left = 0,
        center = 1,
        right = 2
    }

    public enum InputType
    {
        Normal,
        RMB
    }

    public class BD_Label : Label
    {
        int i = 0;
        public BD_Label()
            : base()
        {

        }

        protected override void OnSizeChanged(EventArgs e)
        {
            base.OnSizeChanged(e);
            if (i == 0)
            {
                base.Height = 21;
            }
            i++;
        }



        #region 属性:外观
        private float _fontsize = 9;//字体大小
        private bool _fontbold = false;//是否粗体
        private bool _fontitalic = false;//是否斜体
        private textAlign _textAlign = textAlign.left;
        private String _name = String.Empty;

        [Category("设计")]
        public String NewName
        {
            get
            {
                _name = _name == String.Empty ? base.Name : _name;
                return _name;
            }
            set
            {
                _name = value;
                base.Name = _name;
            }
        }

        [Category("外观")]
        public float FontSize
        {
            set { _fontsize = value; FontChange(); }
            get { return _fontsize; }
        }

        [Category("外观")]
        public bool FontBold
        {
            set { _fontbold = value; FontChange(); }
            get { return _fontbold; }
        }
        [Category("外观")]
        public bool FontItalic
        {
            set { _fontitalic = value; FontChange(); }
            get { return _fontitalic; }
        }

        [Category("外观")]
        public textAlign TextAlign
        {
            set
            {
                _textAlign = value;
                switch (_textAlign)
                {
                    case textAlign.left:
                        base.TextAlign = ContentAlignment.MiddleLeft;
                        break;
                    case textAlign.center:
                        base.TextAlign = ContentAlignment.MiddleCenter;
                        break;
                    case textAlign.right:
                        base.TextAlign = ContentAlignment.MiddleRight;
                        break;
                    default:
                        break;
                }
            }
            get { return _textAlign; }
        }

        void FontChange()
        {
            if (_fontbold && _fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Bold | FontStyle.Italic);
            else if (_fontbold && !_fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Bold);
            else if (!_fontbold && _fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Italic);
        }
        #endregion
    }

    public class BD_TextBox : TextBox
    {
        #region 属性:外观
        private float _fontsize = 9;//字体大小
        private bool _fontbold = false;//是否粗体
        private bool _fontitalic = false;//是否斜体
        private textAlign _textAlign = textAlign.left;
        private InputType _inputType = InputType.Normal;
        private String _name = String.Empty;

        [Category("设计")]
        public String NewName
        {
            get
            {
                _name = _name == String.Empty ? base.Name : _name;
                return _name;
            }
            set
            {
                _name = value;
                base.Name = _name;
            }
        }

        [Category("外观")]
        public float FontSize
        {
            set { _fontsize = value; FontChange(); }
            get { return _fontsize; }
        }

        [Category("外观")]
        public bool FontBold
        {
            set { _fontbold = value; FontChange(); }
            get { return _fontbold; }
        }
        [Category("外观")]
        public bool FontItalic
        {
            set { _fontitalic = value; FontChange(); }
            get { return _fontitalic; }
        }



        [Category("外观")]
        public textAlign TextAlign
        {
            set
            {
                _textAlign = value;
                switch (_textAlign)
                {
                    case textAlign.left:
                        base.TextAlign = HorizontalAlignment.Left;
                        break;
                    case textAlign.center:
                        base.TextAlign = HorizontalAlignment.Center;
                        break;
                    case textAlign.right:
                        base.TextAlign = HorizontalAlignment.Right;
                        break;
                    default:
                        break;
                }
            }
            get { return _textAlign; }
        }

        public InputType InputType
        {
            get { return _inputType; }
            set { _inputType = value; }
        }

        void FontChange()
        {
            if (_fontbold && _fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Bold | FontStyle.Italic);
            else if (_fontbold && !_fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Bold);
            else if (!_fontbold && _fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Italic);
        }
        #endregion
        #region 属性:限制
        private Limitypes _limittype;
        private string _limit = string.Empty;

        [DisplayName("类型"), Category("限制")]
        public Limitypes Limittype
        {
            set { _limittype = value; }
            get { return _limittype; }
        }

        [DisplayName("条件"), Category("限制")]
        public string Limit
        {
            set { _limit = value; }
            get { return _limit; }
        }

        private String formular;
        [Category("杂项")]
        [Description("设计计算公式")]
        [Browsable(true)]
        [Editor(typeof(FormularEdits), typeof(UITypeEditor)), Localizable(true)]
        public String Formular
        {
            get { return formular; }
            set { formular = value; }
        }

        #endregion

        #region 工作流参数
        //private bool _iswfArg;
        private string _argName;
        //[Category("工作流参数")]
        //public bool IswfArg
        //{
        //    set
        //    {
        //        _iswfArg = value;
        //        //SetPropertyVisibility(this, "ArgName", value);
        //    }
        //    get { return _iswfArg; }
        //}

        //private void SetPropertyVisibility(object obj, string propertyName, bool visible)
        //{
        //    try
        //    {
        //        Type type = typeof(BrowsableAttribute);
        //        PropertyDescriptorCollection props = TypeDescriptor.GetProperties(obj);
        //        AttributeCollection attrs = props[propertyName].Attributes;
        //        FieldInfo fld = type.GetField("browsable", BindingFlags.Instance | BindingFlags.NonPublic);
        //        fld.SetValue(attrs[type], visible);
        //    }
        //    catch (Exception ex)
        //    {

        //    }
        //}

        [Category("工作流参数")]
        public string ArgName
        {
            set { _argName = value; }
            get { return _argName; }
        }
        #endregion

        #region 自动绑定参数
        private autobing _autoBind;
        public enum autobing
        {
            不绑定,
            绑定到部门,
            绑定到发起人,
            绑定到日期,
            绑定到编号,
            绑定到职位,
        }

        public autobing AutoBind
        {
            set { this._autoBind = value; }
            get { return this._autoBind; }
        }
        #endregion
    }

    public class BD_RichTextBox : RichTextBox
    {
        #region 属性:外观
        private float _fontsize = 9;//字体大小
        private bool _fontbold = false;//是否粗体
        private bool _fontitalic = false;//是否斜体
        private String _name = String.Empty;

        [Category("设计")]
        public String NewName
        {
            get
            {
                _name = _name == String.Empty ? base.Name : _name;
                return _name;
            }
            set
            {
                _name = value;
                base.Name = _name;
            }
        }

        [Category("外观")]
        public float FontSize
        {
            set { _fontsize = value; FontChange(); }
            get { return _fontsize; }
        }

        [Category("外观")]
        public bool FontBold
        {
            set { _fontbold = value; FontChange(); }
            get { return _fontbold; }
        }
        [Category("外观")]
        public bool FontItalic
        {
            set { _fontitalic = value; FontChange(); }
            get { return _fontitalic; }
        }

        void FontChange()
        {
            if (_fontbold && _fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Bold | FontStyle.Italic);
            else if (_fontbold && !_fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Bold);
            else if (!_fontbold && _fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Italic);
        }
        #endregion
        #region 属性:限制
        private Limitypes _limittype;
        private string _limit = string.Empty;
        [DisplayName("类型"), Category("限制")]
        public Limitypes Limittype
        {
            set { _limittype = value; }
            get { return _limittype; }
        }

        [DisplayName("条件"), Category("限制")]
        public string Limit
        {
            set { _limit = value; }
            get { return _limit; }
        }
        #endregion
    }

    public class BD_Button : Button
    {
        int i = 0;
        protected override void OnResize(EventArgs e)
        {
            base.OnResize(e);
            if (i == 0)
            {
                base.Height = 21;
            }
            i++;
        }

        #region 属性:外观
        private float _fontsize = 9;//字体大小
        private bool _fontbold = false;//是否粗体
        private bool _fontitalic = false;//是否斜体
        private textAlign _textAlign = textAlign.center;
        private String _name = String.Empty;

        [Category("设计")]
        public String NewName
        {
            get
            {
                _name = _name == String.Empty ? base.Name : _name;
                return _name;
            }
            set
            {
                _name = value;
                base.Name = _name;
            }
        }

        [Category("外观")]
        public float FontSize
        {
            set { _fontsize = value; FontChange(); }
            get { return _fontsize; }
        }

        [Category("外观")]
        public bool FontBold
        {
            set { _fontbold = value; FontChange(); }
            get { return _fontbold; }
        }
        [Category("外观")]
        public bool FontItalic
        {
            set { _fontitalic = value; FontChange(); }
            get { return _fontitalic; }
        }

        [Category("外观")]
        public textAlign TextAlign
        {
            set
            {
                _textAlign = value;
                switch (_textAlign)
                {
                    case textAlign.left:
                        base.TextAlign = ContentAlignment.MiddleLeft;
                        break;
                    case textAlign.center:
                        base.TextAlign = ContentAlignment.MiddleCenter;
                        break;
                    case textAlign.right:
                        base.TextAlign = ContentAlignment.MiddleRight;
                        break;
                    default:
                        break;
                }
            }
            get { return _textAlign; }
        }

        void FontChange()
        {
            if (_fontbold && _fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Bold | FontStyle.Italic);
            else if (_fontbold && !_fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Bold);
            else if (!_fontbold && _fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Italic);
        }
        #endregion
    }

    public class BD_CheckBox : CheckBox
    {
        int i = 0;
        protected override void OnResize(EventArgs e)
        {
            base.OnResize(e);
            if (i == 0)
            {
                base.Height = 21;
            }
            i++;
        }

        #region 属性:外观
        private float _fontsize = 9;//字体大小
        private bool _fontbold = false;//是否粗体
        private bool _fontitalic = false;//是否斜体
        private String _name = String.Empty;

        [Category("设计")]
        public String NewName
        {
            get
            {
                _name = _name == String.Empty ? base.Name : _name;
                return _name;
            }
            set
            {
                _name = value;
                base.Name = _name;
            }
        }

        [Category("外观")]
        public float FontSize
        {
            set { _fontsize = value; FontChange(); }
            get { return _fontsize; }
        }

        [Category("外观")]
        public bool FontBold
        {
            set { _fontbold = value; FontChange(); }
            get { return _fontbold; }
        }
        [Category("外观")]
        public bool FontItalic
        {
            set { _fontitalic = value; FontChange(); }
            get { return _fontitalic; }
        }
        void FontChange()
        {
            if (_fontbold && _fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Bold | FontStyle.Italic);
            else if (_fontbold && !_fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Bold);
            else if (!_fontbold && _fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Italic);
        }
        #endregion
    }

    public class BD_RadioButton : RadioButton
    {
        int i = 0;
        protected override void OnResize(EventArgs e)
        {
            base.OnResize(e);
            if (i == 0)
            {
                base.Height = 21;
            }
            i++;
        }

        #region 属性:外观
        private float _fontsize = 9;//字体大小
        private bool _fontbold = false;//是否粗体
        private bool _fontitalic = false;//是否斜体
        private String _name = String.Empty;

        [Category("设计")]
        public String NewName
        {
            get
            {
                _name = _name == String.Empty ? base.Name : _name;
                return _name;
            }
            set
            {
                _name = value;
                base.Name = _name;
            }
        }

        [Category("外观")]
        public float FontSize
        {
            set { _fontsize = value; FontChange(); }
            get { return _fontsize; }
        }

        [Category("外观")]
        public bool FontBold
        {
            set { _fontbold = value; FontChange(); }
            get { return _fontbold; }
        }
        [Category("外观")]
        public bool FontItalic
        {
            set { _fontitalic = value; FontChange(); }
            get { return _fontitalic; }
        }

        void FontChange()
        {
            if (_fontbold && _fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Bold | FontStyle.Italic);
            else if (_fontbold && !_fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Bold);
            else if (!_fontbold && _fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Italic);
        }
        #endregion
    }

    public class BD_ComboBox : ComboBox
    {
        private String _sql;

        [Category("杂项")]
        [Description("数据源\r\n唯有选择操作类型为'绑定数据库'方有效")]
        [Browsable(true)]
        [Editor(typeof(DataSourceEdits), typeof(UITypeEditor)), Localizable(true)]
        public String SQL
        {
            get { return _sql; }
            set { _sql = value; }
        }

        #region 属性:外观
        private float _fontsize = 9;//字体大小
        private bool _fontbold = false;//是否粗体
        private bool _fontitalic = false;//是否斜体
        private String _name = String.Empty;

        [Category("设计")]
        public String NewName
        {
            get
            {
                _name = _name == String.Empty ? base.Name : _name;
                return _name;
            }
            set
            {
                _name = value;
                base.Name = _name;
            }
        }

        [Category("外观")]
        public float FontSize
        {
            set { _fontsize = value; FontChange(); }
            get { return _fontsize; }
        }

        [Category("外观")]
        public bool FontBold
        {
            set { _fontbold = value; FontChange(); }
            get { return _fontbold; }
        }
        [Category("外观")]
        public bool FontItalic
        {
            set { _fontitalic = value; FontChange(); }
            get { return _fontitalic; }
        }
        void FontChange()
        {
            if (_fontbold && _fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Bold | FontStyle.Italic);
            else if (_fontbold && !_fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Bold);
            else if (!_fontbold && _fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Italic);
        }
        #endregion

        private autobing _autoBind;
        public enum autobing
        {
            不绑定,
            绑定到本部门人员,
            绑定到本公司职位
        }

        public autobing AutoBind
        {
            set { this._autoBind = value; }
            get { return this._autoBind; }
        }
    }

    public class BD_PictureBox : PictureBox
    {
        public BD_PictureBox()
            : base()
        {
            this.SizeMode = PictureBoxSizeMode.StretchImage;
        }

        //#region 属性:外观
        private float _fontsize = 9;//字体大小
        private bool _fontbold = false;//是否粗体
        private bool _fontitalic = false;//是否斜体
        private String _imagePath;
        private String _name = String.Empty;

        [Category("设计")]
        public String NewName
        {
            get
            {
                _name = _name == String.Empty ? base.Name : _name;
                return _name;
            }
            set
            {
                _name = value;
                base.Name = _name;
            }
        }

        [Category("外观")]
        public float FontSize
        {
            set { _fontsize = value; FontChange(); }
            get { return _fontsize; }
        }

        [Category("外观")]
        public bool FontBold
        {
            set { _fontbold = value; FontChange(); }
            get { return _fontbold; }
        }
        [Category("外观")]
        public bool FontItalic
        {
            set { _fontitalic = value; FontChange(); }
            get { return _fontitalic; }
        }

        [Category("外观")]
        [Editor(typeof(ImageEdits), typeof(UITypeEditor)), Localizable(true)]
        public new String Image
        {
            get { return _imagePath; }
            set
            {
                this.ImageLocation = value;
                _imagePath = value;
            }
        }

        void FontChange()
        {
            if (_fontbold && _fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Bold | FontStyle.Italic);
            else if (_fontbold && !_fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Bold);
            else if (!_fontbold && _fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Italic);
        }
        //#endregion
    }

    public class BD_DateTimePicker : DateTimePicker
    {

        //#region 属性:外观
        private float _fontsize = 9;//字体大小
        private bool _fontbold = false;//是否粗体
        private bool _fontitalic = false;//是否斜体
        private String _name = String.Empty;

        [Category("设计")]
        public String NewName
        {
            get
            {
                _name = _name == String.Empty ? base.Name : _name;
                return _name;
            }
            set
            {
                _name = value;
                base.Name = _name;
            }
        }

        [Category("外观")]
        public float FontSize
        {
            set { _fontsize = value; FontChange(); }
            get { return _fontsize; }
        }

        [Category("外观")]
        public bool FontBold
        {
            set { _fontbold = value; FontChange(); }
            get { return _fontbold; }
        }
        [Category("外观")]
        public bool FontItalic
        {
            set { _fontitalic = value; FontChange(); }
            get { return _fontitalic; }
        }
        void FontChange()
        {
            if (_fontbold && _fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Bold | FontStyle.Italic);
            else if (_fontbold && !_fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Bold);
            else if (!_fontbold && _fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Italic);
        }
        //#endregion
    }

    public class BD_DataGridView : DataGridView
    {
        public BD_DataGridView()
            : base()
        {
            base.AllowUserToAddRows = true;
        }
        public enum oprType
        {
            绑定数据库,
            手动填写,
            可增表格
        }

        //#region 属性:外观
        private float _fontsize = 9;//字体大小
        private bool _fontbold = false;//是否粗体
        private bool _fontitalic = false;//是否斜体
        private textAlign _textAlign;

        private oprType _operType;
        private String _sql;
        private DataGridViewColumnCollection _columns = null;       // 绑定数据列
        private Object _data = null;                                // 表单填写的数据
        private DataGridViewRowCollection _rows = null;             // 绑定数据行

        public static Int32 Count = 0;                              // 当前设计时该控件的个数
        private String _name = String.Empty;

        [Category("设计")]
        public String NewName
        {
            get
            {
                _name = _name == String.Empty ? base.Name : _name;
                return _name;
            }
            set
            {
                _name = value;
                base.Name = _name;
            }
        }

        [Category("外观")]
        public float FontSize
        {
            set { _fontsize = value; FontChange(); }
            get { return _fontsize; }
        }

        [Category("外观")]
        public bool FontBold
        {
            set { _fontbold = value; FontChange(); }
            get { return _fontbold; }
        }
        [Category("外观")]
        public bool FontItalic
        {
            set { _fontitalic = value; FontChange(); }
            get { return _fontitalic; }
        }
        void FontChange()
        {
            if (_fontbold && _fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Bold | FontStyle.Italic);
            else if (_fontbold && !_fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Bold);
            else if (!_fontbold && _fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Italic);
        }
        //#endregion


        [Category("杂项")]
        [DescriptionAttribute("添加列\r\n唯有选择操作类型为'手动填写'方有效")]
        [BrowsableAttribute(true)]
        [System.Runtime.CompilerServices.SpecialName]
        [RefreshProperties(RefreshProperties.All)]
        [Editor(typeof(CusEdits), typeof(UITypeEditor)), Localizable(false)]
        public new DataGridViewColumnCollection Columns
        {
            get { return _columns; }
            set
            {
                _columns = value;
            }
        }

        [Category("杂项")]
        [Browsable(true)]
        [Description("操作类型")]
        public oprType OperType
        {
            get
            {
                return _operType;
            }
            set
            {
                if (value == oprType.手动填写)
                {
                    SetPropertyVisibility(this, "Columns", true);
                    SetPropertyVisibility(this, "SQL", false);
                    SetPropertyVisibility(this, "Data", true);
                }
                else if (value == oprType.绑定数据库)
                {
                    SetPropertyVisibility(this, "Columns", false);
                    SetPropertyVisibility(this, "SQL", true);
                    SetPropertyVisibility(this, "Data", false);
                }
                else if (value == oprType.可增表格)
                {
                    SetPropertyVisibility(this, "Columns", true);
                    SetPropertyVisibility(this, "SQL", false);
                    SetPropertyVisibility(this, "Data", true);
                }
                this.Refresh();
                _operType = value;
            }
        }


        [Category("杂项")]
        [Description("数据源\r\n唯有选择操作类型为'绑定数据库'方有效")]
        [Browsable(true)]
        [Editor(typeof(DataSourceEdits), typeof(UITypeEditor)), Localizable(true)]
        public String SQL
        {
            get { return _sql; }
            set { _sql = value; }
        }

        [Category("数据")]
        [Description("填写数据")]
        [Browsable(true)]
        [Editor(typeof(DataBindingEdits), typeof(UITypeEditor)), Localizable(true)]
        public Object Data
        {
            get { return _data; }
            set
            {
                _data = value;
                var grdView = (DataGridView)_data;
                //CopyGrdViewData.AddCols(ref this._columns, grdView);

                var rowCount = grdView.Rows.Count;
                var colCount = grdView.Columns.Count;
                this.Rows.Clear();
                this.Rows.Add(rowCount - 1);
                for (int rowIndex = 0; rowIndex < rowCount; rowIndex++)
                {
                    for (int colIndex = 0; colIndex < colCount; colIndex++)
                    {
                        this.Rows[rowIndex].Cells[colIndex].Value = grdView.Rows[rowIndex].Cells[colIndex].Value;
                    }
                }
            }
        }

        private void SetPropertyVisibility(object obj, string propertyName, bool visible)
        {
            Type type = typeof(BrowsableAttribute);
            PropertyDescriptorCollection props = TypeDescriptor.GetProperties(obj);
            AttributeCollection attrs = props[propertyName].Attributes;
            FieldInfo fld = type.GetField("browsable", BindingFlags.Instance | BindingFlags.NonPublic);
            fld.SetValue(attrs[type], visible);
        }
    }

    public class BD_TreeView_Employee : TreeView
    {

        #region 属性:外观
        private float _fontsize = 9;//字体大小
        private bool _fontbold = false;//是否粗体
        private bool _fontitalic = false;//是否斜体
        private String _name = String.Empty;

        [Category("设计")]
        public String NewName
        {
            get
            {
                _name = _name == String.Empty ? base.Name : _name;
                return _name;
            }
            set
            {
                _name = value;
                base.Name = _name;
            }
        }

        [Category("外观")]
        public float FontSize
        {
            set { _fontsize = value; FontChange(); }
            get { return _fontsize; }
        }

        [Category("外观")]
        public bool FontBold
        {
            set { _fontbold = value; FontChange(); }
            get { return _fontbold; }
        }
        [Category("外观")]
        public bool FontItalic
        {
            set { _fontitalic = value; FontChange(); }
            get { return _fontitalic; }
        }
        void FontChange()
        {
            if (_fontbold && _fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Bold | FontStyle.Italic);
            else if (_fontbold && !_fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Bold);
            else if (!_fontbold && _fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Italic);
        }
        #endregion

        public BD_TreeView_Employee()
        {
            var chilNode = new TreeNode[]{ 
                new TreeNode("A员工"),
                new TreeNode("B员工")
            };

            var rootNode = new TreeNode("部门", chilNode);
            this.Nodes.Add(rootNode);
        }
    }

    public class BD_Horizon : UserControl
    {
        private Color lineColor = Color.Black;
        private Int32 lineHeight = 1;

        private Int32 width;


        private static Int32 ctrlCount = 1;
        public BD_Horizon()
        {
            this.width = base.Width;
            this.Height = 2;
            this.Name = ctrlCount.ToString();
            ctrlCount++;
        }

        [Browsable(true)]
        public new Int32 Width
        {
            get { return this.width; }
            set
            {
                this.width = value;
            }
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            e.Graphics.DrawLine(new Pen(lineColor), 1, 1, this.Width, lineHeight);
        }

        protected override void OnSizeChanged(EventArgs e)
        {
            base.OnSizeChanged(e);
            this.Height = 2;
            this.Width = base.Width;
        }


        #region 属性:外观
        private float _fontsize = 9;//字体大小
        private bool _fontbold = false;//是否粗体
        private bool _fontitalic = false;//是否斜体

        [Category("外观")]
        public float FontSize
        {
            set { _fontsize = value; FontChange(); }
            get { return _fontsize; }
        }

        [Category("外观")]
        public bool FontBold
        {
            set { _fontbold = value; FontChange(); }
            get { return _fontbold; }
        }
        [Category("外观")]
        public bool FontItalic
        {
            set { _fontitalic = value; FontChange(); }
            get { return _fontitalic; }
        }

        void FontChange()
        {
            if (_fontbold && _fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Bold | FontStyle.Italic);
            else if (_fontbold && !_fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Bold);
            else if (!_fontbold && _fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Italic);
        }
        #endregion
    }

    public class BD_Vertical : UserControl
    {
        private Color lineColor = Color.Black;
        private Int32 lineWidth = 1;

        private Int32 height;

        private static Int32 ctrlCount = 50;

        public BD_Vertical()
        {
            this.Width = 2;
            this.height = base.Height;
            this.Name = ctrlCount.ToString();
            ctrlCount++;
        }

        [Browsable(true)]
        public new Int32 Height
        {
            get { return height; }
            set
            {
                this.height = value;
            }
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            e.Graphics.DrawLine(new Pen(lineColor), 1, 1, lineWidth, this.Height);
        }

        protected override void OnSizeChanged(EventArgs e)
        {
            base.OnSizeChanged(e);
            this.Width = 2;
            this.Height = base.Height;
        }


        #region 属性:外观
        private float _fontsize = 9;//字体大小
        private bool _fontbold = false;//是否粗体
        private bool _fontitalic = false;//是否斜体

        [Category("外观")]
        public float FontSize
        {
            set { _fontsize = value; FontChange(); }
            get { return _fontsize; }
        }

        [Category("外观")]
        public bool FontBold
        {
            set { _fontbold = value; FontChange(); }
            get { return _fontbold; }
        }
        [Category("外观")]
        public bool FontItalic
        {
            set { _fontitalic = value; FontChange(); }
            get { return _fontitalic; }
        }

        void FontChange()
        {
            if (_fontbold && _fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Bold | FontStyle.Italic);
            else if (_fontbold && !_fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Bold);
            else if (!_fontbold && _fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Italic);
        }
        #endregion
    }

    #endregion
}
